//
//  RowUploadImagesM.m
//  
//  jhf
//
//  Created by Mac on 2020/8/13.
//  Copyright © 2020 jhfappkf@163.com. All rights reserved.
//

#import "RowUploadImagesM.h"

@implementation RowUploadImagesM

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self defaultConfig];
    }
    return self;
}

- (void)defaultConfig {
    self.cellSize = CGSizeMake(120, 120);
    self.needMove = true;
    self.delActionDrowOut = true;
    self.addLocation = false;
    self.maxNum = 9;
    self.minimumLineSpacing = 8;
    self.minimumInteritemSpacing = 8;
    self.sectionInset = UIEdgeInsetsZero;
    self.numberOfVertail = 4;
}

+ (RowUploadImagesM *)defaultAddImageName:(NSString *)addImageName dataKey:(NSString *)dataKey; {
    RowUploadImagesM *controlM = [[RowUploadImagesM alloc] init];
    controlM.dataKey = dataKey;
    controlM.addImageName = addImageName;
    return controlM;
}

//
- (JAddImageModel *)addBT {
    if (!_addBT) {
        JAddImageModel *model = [JAddImageModel nameImgToImgModel:self.addImageName];
        model.isAddBtn = true;
        if (self.vRadio > 0) {
            model.vRadius = self.vRadio;
        }
        _addBT = model;
    }
    return _addBT;
}

- (NSMutableArray<JAddImageModel *> *)dataArray {
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (NSMutableArray <JAddImageModel *> *)currentShowDataArray; {
    NSMutableArray *tempArray = [NSMutableArray array];
    [self.dataArray enumerateObjectsUsingBlock:^(JAddImageModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if (self.vRadio > 0) {
            obj.vRadius = self.vRadio;
            obj.vMasksToBounds = true;
        }
        if (!obj.isAddBtn) {
            [tempArray addObject:obj];
        }
    }];
    if (tempArray.count < self.maxNum) {
        if (self.addLocation) {
            [tempArray insertObject:self.addBT atIndex:0];
        }else {
            [tempArray addObject:self.addBT];
        }
    }
    return tempArray;
}

@end
